'''
for...in循环
'''

#表1
for row in range(1,10):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(col,row,col*row),end=' ')
    print(' ')
print('='*80)
print(' ')

#表2
for row in range(9,0,-1):
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format(col,row,col*row),end=' ')
    print(' ')
print('='*80)
print(' ')

#表3
for row in range(1,10):
    for block in range(1,10-row):
        print(end='         ')
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format((row-col+1),row,(row-col+1)*row),end=' ')
    print(' ')
print('='*80)
print(' ')

#表4
for row in range(9,0,-1):
    for block in range(1,10-row):
        print(end='         ')
    for col in range(1,row+1):
        print('{}*{}={:<4}'.format((row - col + 1), row, (row - col + 1) * row), end=' ')
    print(' ')
print('='*80)
print(' ')

'''
while循环
'''

#表1
row = 1
while row<=9:
    col = 1
    while col<=row:
        print('{}*{}={:<4}'.format(col, row, col * row), end=' ')
        col = col+1
    print(' ')
    row = row+1
print('='*80)
print(' ')

#表2
row = 9
while row>=1:
    col = 1
    while col<=row:
        print('{}*{}={:<4}'.format(col, row, col * row), end=' ')
        col = col + 1
    print(' ')
    row = row-1
print('='*80)
print(' ')

#表3
row = 1
while row<=9:
    block = 1
    col = 1
    while block<=(9-row):
        print(end='         ')
        block = block+1
    while col<=row:
        print('{}*{}={:<4}'.format((row - col + 1), row, (row - col + 1) * row), end=' ')
        col = col+1
    print(' ')
    row = row+1
print('='*80)
print(' ')

#表4
row = 9
while row>=1:
    block = 1
    col = 1
    while block<=(9-row):
        print(end='         ')
        block = block + 1
    while col<=row:
        print('{}*{}={:<4}'.format((row - col + 1), row, (row - col + 1) * row), end=' ')
        col = col+1
    print(' ')
    row = row-1
print('='*80)
print(' ')


